#ifndef HIBARRIER_HPP
#define HIBARRIER_HPP

// variation of boost::barrier

#include <boost/thread.hpp>
#include <boost/throw_exception.hpp>

#include <string>
#include <stdexcept>

namespace hi
{
    class Barrier
    {
    public:
        Barrier(unsigned int count);
    
        bool wait();
		
		bool decrement();
		
		void increment();

    private:
		boost::mutex m_mutex;
        boost::condition_variable m_cond;
        unsigned int m_threshold;
        unsigned int m_count;
        unsigned int m_generation;
    };
}   // namespace hi

#endif
